/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 * Description: 性能评估器相关源文件
 * Author: sunzhepeng
 * Create: 2022-8-1
 */

#include "connected_subgraph.h"
#include "evaluator_log_def.h"

namespace HcclEvaluator {
ConnectedSubgraph::ConnectedSubgraph(AdjacencyMatrix<> &&matrix) : matrix_(std::forward<AdjacencyMatrix<> &&>(matrix)),
    nodeSize_(matrix.GetNodeNum())
{
}

HcclResult ConnectedSubgraph::GetHockneyModelParam(HockneyModelParam &param)
{
    for (u32 i = 0; i < nodeSize_; i++) {
        for (u32 j = 0; j < nodeSize_; j++) {
            if (i == j) {
                continue;
            }
            AdjaMatrixEdge edge = matrix_.GetEdgeByIndex(i, j);
            if (edge.IsConnected()) {
                param.alpha = edge.ports->staticDelay;
                param.beta = 1.0 / edge.ports->bandWidth;
                param.gamma = 0;
                return HCCL_SUCCESS;
            }
        }
    }
    EVALUATOR_ERROR("No Connected Node\n");
    return HCCL_E_PARA;
}
} // namespace HcclEvaluator